﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TankIt.Models
{
    public class Hand : IComparable<Hand>
    {
        public Guid HandID { get; set; }
        public List<Card> Cards { get; set; }

        public Hand()
        {
            this.HandID = Guid.NewGuid();
            this.Cards = new List<Card>();
        }

        public override string ToString()
        {
            string hand = "";
            foreach (var c in this.Cards)
            {
                string temp = c.ToShortString();
                hand = hand + " " + temp;
            }
            return hand;
        }


        public virtual int CompareTo(Hand that)
        {
            int thisTotal = this.Cards.Sum(s => (int)s.CValue);
            int thatTotal = that.Cards.Sum(s => (int)s.CValue);

            return thisTotal.CompareTo(thatTotal);
        }

    }
}